package com.xfly.app.ui;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.text.TextUtils;
import android.view.View;

import com.ptmall.app.R;
import com.ptmall.app.base.BaseMvpActivity;
import com.ptmall.app.ui.fragment.FyFragment;
import com.ptmall.app.view.TitleBarView;

import java.util.ArrayList;
import java.util.List;


public class FyActivity extends BaseMvpActivity {


    TabLayout mCommonTab;
    ViewPager mCommonVp;
    TitleBarView titleBarView;

    private List<String> mTabNames= new ArrayList<>();
    private List<Fragment> mFragmentList = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setView(R.layout.activity_fy);
    }

    @Override
    public void initViews() {
        titleBarView = findViewById(R.id.title);
        mCommonTab = findViewById(R.id.common_tab);
        mCommonVp = findViewById(R.id.common_vp);
        titleBarView.setText("分佣管理");
        titleBarView.setOnTitleBarClickListener(new TitleBarView.TitleBarClickListener() {
            @Override
            public void leftClick() {
                finish();
            }

            @Override
            public void rightClick() {

            }
        });
    }

    @Override
    public void initEvents() {
        mTabNames.add("待发放");
        mTabNames.add("已发放");

        mFragmentList.add(FyFragment.newInstance("1"));
        mFragmentList.add(FyFragment.newInstance("2"));

        mCommonVp.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                return mFragmentList.get(position);
            }

            @Override
            public int getCount() {
                return mTabNames.size();
            }

            @Override
            public CharSequence getPageTitle(int position) {
                return mTabNames.get(position);
            }
        });
        mCommonTab.setupWithViewPager(mCommonVp);
    }
}
